import request from "./request.js";
import server_url from "./config";
export function login(data) {
  return request({
    url: "/api/user/login",
    method: "get",
    data,
  });
}

export function getList(data) {
  return request({
    url: "/api/business/list",
    method: "get",
    data,
  });
}

// 商家产品分类
export function getTypeList(data) {
  return request({
    url: "/api/category/list",
    method: "get",
    data,
  });
}
// 商品分类
export function getGoodsList(data) {
  return request({
    url: "/api/goods/list",
    method: "get",
    data,
  });
}

// 商品详情
export function getGoodsDetail(data) {
  return request({
    url: "/api/goods/detail",
    method: "get",
    data,
  });
}

// 下单
export function createOrder(data) {
  return request({
    url: "/api/order/create",
    method: "post",
    data,
  });
}

// 获取费用
export function getFee(data) {
  return request({
    url: "/api/order/fee",
    method: "post",
    data,
  });
}

// 支付
export function pay(data) {
  return request({
    url: "/api/order/wxpay",
    method: "get",
    data,
  });
}

// 获取地址
export function getAddressList(data) {
  return request({
    url: "/api/userAddress/list",
    method: "get",
    data,
  });
}

// 新增收货地址
export function addAddress(data) {
  return request({
    url: "/api/userAddress/add",
    method: "post",
    data,
  });
}

// 编辑地址
export function editAddress(data) {
  return request({
    url: "/api/userAddress/edit",
    method: "post",
    data,
  });
}

// 地址删除
export function deleteAddress(data) {
  return request({
    url: "/api/userAddress/delete",
    method: "get",
    data,
  });
}

// 订单列表
export function getOrder(data) {
  return request({
    url: "/api/order/list",
    method: "get",
    data,
  });
}

export function getOrderDetail(data) {
  return request({
    url: "/api/order/detail",
    method: "get",
    data,
  });
}

export function confirmComplate(data) {
  return request({
    url: "/api/order/complete",
    method: "get",
    data,
  });
}

export function getOrderStatus(data) {
  return request({
    url: "/api/order/process",
    method: "get",
    data,
  });
}

export function cancelOrder(data) {
  return request({
    url: "/api/order/cancel",
    method: "get",
    data,
  });
}

//取消并退款
export function cancelOrder2(data) {
  return request({
    url: "/api/order/refund",
    method: "get",
    data,
  });
}

// 评价
export function evaluateOrder(data) {
  return request({
    url: "/api/orderComment/add",
    method: "post",
    data,
  });
}

// 商家评价
export function getBusinessComment(data) {
  return request({
    url: "/api/orderComment/list",
    method: "get",
    data,
  });
}

// 首页优惠卷
export function getReductionList() {
  return request({
    url: "/api/reduction/available",
    method: "get",
  });
}

// 领取优惠券
export function getObtain(data) {
  return request({
    url: "/api/reduction/obtain",
    method: "post",
    data,
  });
}

// 首页优惠卷
export function getBusinessCategory() {
  return request({
    url: "/api/tBusinessCategory/list",
    method: "get",
  });
}

// 首页banner
export function getBanner() {
  return request({
    url: "/api/tBanner/list",
    method: "get",
  });
}
// message
export function getMessage() {
  return request({
    url: "/api/tConfig/message",
    method: "get",
  });
}

// message
export function getMyInfo() {
  return request({
    url: "/api/user/my",
    method: "get",
  });
}

export function upDateInfo(data) {
  return request({
    url: "/api/user/edit",
    method: "post",
    data,
  });
}
export function upLoadFile() {
  return `${server_url}/api/common/upload`;
}
